def is_leap_year(year):
    if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
        return True
    return False


def next_date(year, month, day):
    days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    if month < 1 or month > 12:
        raise ValueError("月份必须在1-12之间")
    if day < 1:
        raise ValueError("日期必须大于0")

    if month == 2 and is_leap_year(year):
        max_day = 29
    else:
        max_day = days_in_month[month - 1]

    if day > max_day:
        raise ValueError(f"{year}年{month}月最多有{max_day}天")


    day += 1

    if day > max_day:
        day = 1
        month += 1
        if month > 12:
            month = 1
            year += 1

    return (year, month, day)


if __name__ == "__main__":
    try:
        y = int(input("请输入年份："))
        m = int(input("请输入月份："))
        d = int(input("请输入日期："))

        next_y, next_m, next_d = next_date(y, m, d)
        print(f"明天的日期是：{next_y}年{next_m}月{next_d}日")
    except ValueError as e:
        print(f"输入错误：{e}")